package com.powernode.ssm.handler;

import com.powernode.ssm.bean.Student;
import com.powernode.ssm.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 曾铖坚
 * @Date: 2024/10/11 17:47
 * @Version: 1.0.0
 */
@RestController
@RequestMapping("/users")
public class StudentHandler {
    @Autowired
    private StudentService service;


    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public Student detail(@PathVariable("id") Integer id) {
        return service.getBySid(id);
    }

    @PostMapping(value = "/")
    public String add(Student student) {
        int count = service.add(student);
        return count != 0 ? "新增失败！" : "新增成功！";
    }
}
